package cn.iocoder.yudao.module.member.agency.service;

import cn.iocoder.yudao.framework.business.basic.dao.query.CoreQueryWrapper;
import cn.iocoder.yudao.framework.business.basic.pojo.vo.UserSimpleVO;
import cn.iocoder.yudao.framework.business.order.service.AdminOrderBaseService;
import cn.iocoder.yudao.module.api.member.user.MemberUserApi;
import cn.iocoder.yudao.module.member.agency.dal.dataobject.AgencyOrderDO;
import cn.iocoder.yudao.module.member.agency.dal.mysql.AgencyOrderMapper;
import cn.iocoder.yudao.module.member.agency.vo.AdminAgencyOrderQueryDTO;
import cn.iocoder.yudao.module.member.agency.vo.AdminAgencyOrderVO;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.Collection;
import java.util.Map;

/**
 * 招商人员身份订单 Service 实现类
 *
 * @author 山野羡民
 */
@Slf4j
@Service
@Validated
public class AdminAgencyOrderServiceImpl extends AdminOrderBaseService<AgencyOrderDO, AdminAgencyOrderVO, AdminAgencyOrderQueryDTO> implements AdminAgencyOrderService {
    @Resource
    private AgencyOrderMapper agencyOrderMapper;

    @Resource
    private MemberUserApi memberUserApi;

    @Override
    protected AgencyOrderMapper getInjectedMapper() {
        return agencyOrderMapper;
    }

    @Nonnull
    @Override
    protected CoreQueryWrapper<AgencyOrderDO> buildQueryWrapper(AdminAgencyOrderQueryDTO param) {
        CoreQueryWrapper<AgencyOrderDO> wrapper = super.buildQueryWrapper(param);
        wrapper.eqIfPresent("package_id", param.getPackageId());
        return wrapper;
    }

    @Nonnull
    @Override
    protected Map<Long, UserSimpleVO> getUserSimpleMap(Collection<Long> userIds) {
        return memberUserApi.getUserSimpleMap(userIds);
    }

}